#{extends 'site.html' /} 
#{set title:'Search quiz' /}

<h2>Search Quiz</h2>

<ul class="addingItem">
	<li>
		<a href="@{Quizzes.create()}">Or add a new one</a>
	</li>
</ul>

#{form @Quizzes.search()} 

	  <table class="table-filter">
      <tbody>
         <tr>
            <td align="right"><label for="quizTitle">Title: </label></td>
            <td><input type="text" name="quizTitle" id="quizTitle" value="${quizTitle}" /></td>
            <td align="right"><label for="difficulty">Min difficulty: </label></td>
            <td>#{difficulty star:difficulty/}</td>
         </tr>
         <tr>
            <td align="right"><label for="second">Min time: </label></td>
            <td><input type="text" name="second"   id="second" value="${second}" /><span class="info"> (seconds)</span></td>
            <td align="right"><label for="groupType">Type: </label> </td>
            <td>#{select 'groupType', items:models.GroupType.findAll(true), valueProperty:'id', value:groupType, labelProperty:'name', id:'group_types' /}</td>
         </tr>
         <tr>
            <td align="right"><label for="nbQuestion">Questions: </label> </td>
            <td><input type="text" name="nbQuestion" id="nbQuestion" value="${nbQuestion}" /></td>
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
         </tr>
      </tbody>
   </table>
   
     <p>
        <input type="submit" value="Search" />
     </p>
  
  #{/form} 
	
<div>
	<table>
		<thead>
			<tr>
				<th>Title</th>
	            <th>Difficulty</th>
	            <th>Questions</th>
	            <th>Time</th>
	            <th>Type</th>
			</tr>
		</thead>
		<tbody>
		  #{list items:quizzes, as:'quiz'}
			<tr>
				<td>#{a @Quizzes.view(quiz.id)}${quiz.title}#{/a}</td>
            <td>#{difficulty star:quiz.difficulty, discriminator:quiz.id, readonly:true, split:true/}</td>
            <td>${quiz.questions.size()}</td>
            <td>${quiz.second}</td>
            <td>
               <ul>
	               #{list items:quiz.groupTypes, as:'types'}
	                  <li>${types.name}</li>
	               #{/list}
               </ul>
            </td>
			</tr>
			#{/list}
			#{else}
			<tr>
			   <td colspan="5" class="no-response">No quiz. Change filter values.</td>
			</tr>
			#{/else}
		</tbody>
	</table>

</div>








